function log(msg){
    CNL.sendMessage({method: "log", arg: msg});
}
log("cnl popup opened!");
$(window).click(function (e) {
    if (isEventActivateCNL(e)){
        //Note: in CnlSelection, we use e.rangeParent, e.rangeOffset
        //to detect the clickedWord.
        //But only FF have those properties (not Chrome, not jQuery,..)
        e = e.originalEvent;
        var query = CnlSelection.getClickedSelectionText(e);
        if (!query)
            query = CnlSelection.getClickedWord(e);
        var remind = CnlSelection.getClickedSentence(e, false);
        log(["clicked!", query]);
        CNL.sendMessage({method: "doQuery", arg: {query: query, remind: remind, srcIdx: null}});
        return false;//to stopPropagation & preventDefault
    }
});
function isEventActivateCNL(e){
    return e.button == 2 && e.shiftKey;
}
